home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / igps_102.zip / DLG_HOST.CPP next >
C/C++ Source or Header  |  1994-06-23  |  3KB  |  86 lines

  1. ////////////////////////////////////////////////////////////////////////////////////
  2. // Internet Global Phone Project
  3. // dlg_host.cpp : implementation file for trivial dialog box class
  4. //
  5. // Dialog box used in requests for IP address from user.
  6. //
  7. ////////////////////////////////////////////////////////////////////////////////////
  8. // Copyright (c) 1993-1994    microWonders Inc.  All rights reserved.
  9. //                                                                         
  10. // AN OPEN INVITION TO BUILD UPON AND CONTRIBUTE TO THE PUBLIC TECHNOLOGY POOL:
  11. // You are encouraged to redistribute, and build upon the technologies presented 
  12. // in this source module and the accompanying article in Dr. Dobb's Journal provided 
  13. // all the conditions listed in the MUSTREAD.TXT file, included with this 
  14. // distribution, are met.
  15. ////////////////////////////////////////////////////////////////////////////////////
  16.  
  17.  
  18. #include "stdafx.h"
  19. #include "mphone.h"
  20.  
  21. #include "winsock.H"  // use winsock for inet_addr and inet_ntoa, UI stuff
  22. #include "dlg_host.h" 
  23.  
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char BASED_CODE THIS_FILE[] = __FILE__;
  27. #endif
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CDlgHostID dialog
  31.  
  32.  
  33. CDlgHostID::CDlgHostID(CWnd* pParent /*=NULL*/)
  34.     : CDialog(CDlgHostID::IDD, pParent)
  35. {
  36.     //{{AFX_DATA_INIT(CDlgHostID)
  37.     m_inputAddress = "";
  38.     //}}AFX_DATA_INIT
  39. }
  40.  
  41. void CDlgHostID::DoDataExchange(CDataExchange* pDX)
  42. {
  43.     CDialog::DoDataExchange(pDX);
  44.     //{{AFX_DATA_MAP(CDlgHostID)
  45.     DDX_Text(pDX, IDC_HOSTADDR, m_inputAddress);
  46.     DDV_MaxChars(pDX, m_inputAddress, 50);
  47.     //}}AFX_DATA_MAP
  48. }
  49.  
  50. BEGIN_MESSAGE_MAP(CDlgHostID, CDialog)
  51.     //{{AFX_MSG_MAP(CDlgHostID)
  52.     ON_BN_CLICKED(IDOK, OnHostIDOK)
  53.     //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55.  
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CDlgHostID message handlers
  59.  
  60. void CDlgHostID::OnHostIDOK()
  61. {
  62.     UpdateData(TRUE);
  63.     if ((m_InetAddress = inet_addr(m_inputAddress)) == INADDR_NONE)
  64.     {   
  65.       AfxMessageBox("Please correct the IP address entered.");
  66.     } 
  67.     else
  68.      CDialog::OnOK();
  69.     
  70. }
  71.  
  72.  
  73. BOOL CDlgHostID::OnInitDialog()
  74. {   
  75.     struct in_addr *inp;
  76.     ULONG tmp_addr;
  77.     tmp_addr = htonl(m_InetAddress);   // to network representation
  78.     inp = (struct in_addr *) &tmp_addr;
  79.     m_inputAddress = inet_ntoa(*inp) ; 
  80.     CDialog::OnInitDialog();
  81.     
  82.     
  83.     
  84.     return TRUE;  // return TRUE  unless you set the focus to a control
  85. }
  86.